//
//  ThreeCollectionViewCell.m
//  12.30_homework_豆瓣电影MVC
//
//  Created by dllo on 16/1/7.
//  Copyright © 2016年 lanou3g. All rights reserved.
//

#import "ThreeCollectionViewCell.h"
#import "ThreeModel.h"
#import "UIImageView+WebCache.h"

@interface ThreeCollectionViewCell ()

@property (nonatomic, retain) UIImageView *imgView;
@property (nonatomic, retain) UILabel *title;

@end

@implementation ThreeCollectionViewCell

- (void)dealloc {
    [_imgView release];
    [_title release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}
- (void)setThreeModel:(ThreeModel *)threeModel {
    
    if (_threeModel != threeModel) {
        [_threeModel release];
        _threeModel = [threeModel retain];
        
        [self getValue];
    }
    
}

- (void)getValue {
    
    self.title.text = _threeModel.title;
    self.title.text = _threeModel.title;
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:_threeModel.image] placeholderImage:[UIImage imageNamed:@"picholder@2x"]];

}


- (void)createSubViews {
    
    self.imgView = [[UIImageView alloc] init];
    [self.contentView addSubview:_imgView];
    [_imgView release];
    
    self.title = [[UILabel alloc] init];
    [self.contentView addSubview:_title];
    [_title release];
    
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    
    _imgView.frame = CGRectMake(0, 0, layoutAttributes.frame.size.width, layoutAttributes.frame.size.height - 50);
    _imgView.backgroundColor = [UIColor cyanColor];
    
    _title.frame = CGRectMake(0, layoutAttributes.frame.size.height - 50, layoutAttributes.frame.size.width, 50);
    _title.backgroundColor = [UIColor clearColor];
    _title.textAlignment = NSTextAlignmentCenter;
    
}


@end
